<script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>
<header class="demo-header">
    <div class="title3Left flt text-center header-small">
        <a href="javascript:history.back(-1);" class="whiteC">
        	<img src="/img/back.png" class="backimg">返回
        </a>
    </div>
    <div class="title3Middle flt text-center">买家订单</div>
</header>
<div class="graybg">
	<div class="fudong" style="background-color: #F8F8F8;height: 45px;">
	    <form action="/product" method="get" class="am-form flt">
	        <div class="am-form-group">
	            <input type="text" class="am-form-field" id="showProdcuts" name="productKey" placeholder="请输入活动名称关键字" autofocus>
	        </div>
	    </form>
	    <a href="index.html">
	    	<div class="header-message flt cuxiao-font" style="padding-top: 5px;color: white;">取消</div>
	    </a>
	</div>
	<div class="shaixuan whitebg">
		<div class="four1 four Cgray" onclick="checkToptab('time',this)">订单时间<img src="/img/order_down.png" class="img-middle oimg padding-adjust2" id="test1"/></div>
		<div class="flt seek-bar" style="padding: 12px 0;"></div>
		<div class="four2 four Cgray" onclick="checkToptab('type',this)">订单状态<img src="/img/order_down.png" class="img-middle oimg padding-adjust2"/></div>
	</div>
	<div class="whitebg" id="whitebg">
        <?php if($this ->order_res){?>
            <?php foreach ($this ->order_res as $v){?>
                <?php if(isset($v['order_code'])){ ?>
                    <div class="sizecolor flt">订单号：<?php echo $v['order_code']; ?></div><div class="frt zonge" style=""><?php echo $v['order_status']?></div>
                <?php }?>
                <div class="clear_both"></div>
                <div class="message-detail">
                    <?php if(isset($v['detail_list'])){?>
                        <p>支付状态：<?php echo $v['pay_status']?></p>
                    <?php }?>
                    <?php if(isset($this->user_res['nickname']) && isset($v['order_code'])){?>
                        <p>卖家名称：<?php echo $this->user_res['nickname']?></p>
                    <?php }?>
                    <?php if(isset($v['detail_list']['amount'])){?>
                        <p>产品数量：<?php echo $v['detail_list']['amount']?></p>
                    <?php }?>
                    <?php if(isset($v['contact'])){?>
                        <p style="padding-left: 3%;">收件人：<?php echo $v['contact'];?></p>
                    <?php }?>
                    <?php if(isset($v['tel'])){?>
                        <p>联系电话：<?php echo $v['tel'];?></p>
                    <?php }?>
                    <?php if(isset($v['insert_time'])){?>
                        <p>订单时间：<?php echo $v['insert_time'];?></p>
                    <?php }?>
                    <?php if(isset($v['adds'])){?>
                        <p>收货地址：<?php echo $v['adds']; ?></p>
                    <?php }?>
                    <?php if(isset($v['remark'])){?>
                        <p>备注信息：<span class="buy-beizhu"><?php echo $v['remark']?></span></p>
                    <?php }?>
                    <?php if(isset($v['logistics_name'])){?>
                        <?php if($v['order_status'] != '待配送'){?>
                            <p>物流方式：<?php echo $v['logistics_name']; ?></p>
                        <?php }?>
                    <?php }?>
                    <?php if(isset($v['logistics_numbers'])){?>
                        <?php if($v['order_status'] != '待配送'){?>
                            <p>物流单号：<span class="buy-beizhu"><?php echo $v['logistics_numbers']?></span></p>
                        <?php }?>
                    <?php }?>
                </div>
                <?php if(isset($v['total_price'])){?>
                    <div class="padding-adjust4 border1">
                        <div class="flt product">订单金额：<span class="money-color" style="font-size: 1.2em;"><strong>￥<?php echo $v['total_price'];?></strong></span></div>
                        <?php if($v['order_status'] == '待配送'){?>
                            <div onclick="ShowAccount(<?php echo $v['id']; ?>);" class="button-two Corange" style="border: 1px solid #EF5507;">立即配送</div>
                        <?php }?>
                    </div>
                <?php }?>
            <?php }?>
        <?php }?>
	</div>
</div>
<form>
    <div id="guige" style="top: 135px;bottom: auto;height: 123px;">
    	<div id="timeserch" class="disn padding-adjust5 div-center" style="width: 96%;">
			<div class="time-input noclick padding-adjust3">
				<div class="flt cuxiao-font" style="width: 50%;">
                                                开始时间<input id="start_time" type="text" class="sort-form-input data-padding" name="start_time" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:end_time.value})" readonly="readonly" value="<?php echo isset($this->start_time) ? $this->start_time : '' ?>" />
                </div>
				<div class="flt cuxiao-font" style="width: 50%;">
                                                 结束时间<input id="end_time" type="text" class="sort-form-input data-padding" name="end_time" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:start_time.value})" readonly="readonly" value="<?php echo isset($this->end_time) ? $this->end_time : '' ?>" />
                </div>
			</div>
    	</div>
    	<div id="typeserch" class="disn padding-adjust5 sort-input">
			<div>待发货</div><div>配送中</div><div>已完成</div>
    	</div>
	    <div class="sort-bottom padding-adjust5" onclick="Closesearch()">确定</div>
        
    </div>
</form>
<div id="fade" class="black_overlay" style="height: 70%;bottom: 0;top: auto;" onclick="Closesearchl()"></div>
<div id="account" class="invoiceguige">
	<div class="invoice-fuceng">
		<div class="text-center">立即配送</div>
	    <form action="/product" method="get" class="am-form flt">
	        <div class="am-form-group" style="margin: 18px 0 12px;">
	            <input type="text" class="am-radius" id="express" name="" placeholder="请输入快递方式" autofocus>
	        </div>
	        <div class="am-form-group">
	            <input type="text" class="am-radius" id="number" name="" placeholder="请输入快递单号">
	        </div>
	    </form>
	</div>
    <input value="order_id" type="text" id="id" class="order_id" style="display: none;">
	<div class="invoice-confirm" onclick="CloseAccount()" style="padding-left: 0;"><strong>确定</strong></div>
</div>
<div id="fadeAccount" class="black_overlay"></div>
<script type="text/javascript">
    $(function () {
        $('#showProdcuts').bind('input', function () {
            var search = $(this).val();
            console.log(search);
            if (search) {
                $.ajax({
                    url: '',
                    type: 'POST',
                    dataType: 'JSON',
                    async: true,
                    data: {'type': 'searchProduct', 'search': search},
                    success: function (info) {
                        if (info.code != 200) {
                            var index = layer.msg('还没有你要搜索的活动...', {icon: 15, shade: 0.1, time: 1800});
                        }
                    }
                });
            }
        });
    });
    function Closesearch() {
        reset();
        $("#guige,#fade").fadeOut();
        $(".four1,.four2,.four3,four4").find('img').attr('src','/img/order_down.png');
        $(".four").addClass('Cgray');
        $('body,.layout_content').css({"overflow":""});
        $('.layout_content').css({"height":"auto"});
        var start_time = $('#start_time').val();
        var end_time = $('#end_time').val();
        if (start_time > end_time) {
            layer.alert('对不起，查询下单时间，开始时间不能大于结束时间');
            return false;
        }
        if (start_time <= end_time) {
            var url = '/my/order';
            $.post(url,{'start_time':start_time,'end_time':end_time,'type':'text',},function (res) {
                if(res.code != 200) {
                    console.log(res.massage);
                } else {
                    var index = layer.msg('搜索完成...', {icon: 15, shade: 0.1, time: 1800});
                }
            });
        }
    }
    function CloseAccount(){
        $("#account,#fadeAccount").fadeOut();
        $('body,.layout_content').css("overflow","");
        var express = $('#express').val();
        var id = $('#id').val();
        var number = $('#number').val();
        var order_number = $('#order_number').val();
        if(!express){
            layer.alert('快递方式不能为空');
        }
        if(!number){
            layer.alert('快递单号不能为空');
        }
        if (start_time <= end_time) {
            var url = '/my/logistics';
            $.post(url,{'express':express,'id':id,'type':'text','number':number},function (res) {
                if(res.code != 200) {
                    console.log(res.massage);
                } else {
                    var index = layer.msg('提交成功', {icon: 16,shade: 0.01,time:1000000});
                    window.location.reload();
                }
            });
        }
    }
    //时间显示
    var now = new Date(); 
    var myDate=new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate();
    document.getElementById("start_time").setAttribute("placeholder",myDate);
    var day=now.getDate()+1;
    myDateEnd=new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + day;
    document.getElementById("end_time").setAttribute("placeholder",myDateEnd);
    function Closesearchl() {
        $("#guige,#fade").fadeOut();
    }
</script>